/**
    入驻小区
**/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            floorShareInfo: {
                floorShares: [],
                total: 0,
                records: 1,
                moreCondition: false,
                fsmId: '',
                floorNum:'',
                conditions: {
                    floorId: '',
                    communityId: '',
                }
            }
        },
        _initMethod: function () {
            vc.emit('selectCommunityFloor', 'initCommunityFloor', {
                callBack: function (_floor) {
                    $that.floorShareInfo.conditions.floorId = _floor.floorId;
                    $that.floorShareInfo.floorNum = _floor.floorNum;
                    $that._listFloorShares(DEFAULT_PAGE, DEFAULT_ROWS);
                }
            });
           
        },
        _initEvent: function () {

            vc.on('floorShare', 'listFloorShare', function (_param) {
                $that._listFloorShares(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listFloorShares(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listFloorShares: function (_page, _rows) {

                $that.floorShareInfo.conditions.page = _page;
                $that.floorShareInfo.conditions.row = _rows;
                $that.floorShareInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
                let param = {
                    params: $that.floorShareInfo.conditions
                };

                //发送get请求
                vc.http.apiGet('/meter.listFloorShareMeter',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.floorShareInfo.total = _json.total;
                        $that.floorShareInfo.records = _json.records;
                        $that.floorShareInfo.floorShares = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.floorShareInfo.records,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddFloorShareModal: function () {
                vc.emit('addFloorShare', 'openAddFloorShareModal', {
                    floorId:$that.floorShareInfo.conditions.floorId,
                    floorNum:$that.floorShareInfo.floorNum,
                });
            },
            _openEditFloorShareModel: function (_floorShare) {
                vc.emit('editFloorShare', 'openEditFloorShareModal', _floorShare);
            },
            _openDeleteFloorShareModel: function (_floorShare) {
                vc.emit('deleteFloorShare', 'openDeleteFloorShareModal', _floorShare);
            },
            _queryFloorShareMethod: function () {
                $that._listFloorShares(DEFAULT_PAGE, DEFAULT_ROWS);

            },
            _moreCondition: function () {
                if ($that.floorShareInfo.moreCondition) {
                    $that.floorShareInfo.moreCondition = false;
                } else {
                    $that.floorShareInfo.moreCondition = true;
                }
            }


        }
    });
})(window.vc);
